package com.tem.system.service.impl;

import com.api.manage.pojo.system.SysBranchOfficeResources;
import com.api.manage.pojo.system.SysCompanyBean;
import com.api.manage.pojo.system.SystemLevelBranchBean;
import com.tem.system.entity.SysBranchOffice;
import com.api.manage.pojo.system.SysBranchOfficeBean;
import com.tem.system.mapper.SysBranchOfficeMapper;
import com.tem.system.service.ISysBranchOfficeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tem.system.service.ISystemLevelBranchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 分公司 分店 服务实现类
 * </p>
 *
 * @author 腾木
 * @since 2023-11-17
 */
@Service
public class SysBranchOfficeServiceImpl extends ServiceImpl<SysBranchOfficeMapper, SysBranchOffice> implements ISysBranchOfficeService {
    @Autowired
    private ISystemLevelBranchService systemLevelBranchService;
    public SysBranchOfficeResources getAllResources(Long sysBranchOfficeId){
        SysBranchOffice sysBranchOffice=this.getById(sysBranchOfficeId);
        if(sysBranchOffice==null)return null;
        SysBranchOfficeResources resources = new SysBranchOfficeResources();
        BeanUtils.copyProperties(sysBranchOffice,resources);
        resources.setSystemLevelBranchs(systemLevelBranchService.getSystemLevelBranchResources(sysBranchOfficeId));
        return resources;
    }
}
